package com.ruoyi.lxzx.mapper;

import java.util.List;

import com.ruoyi.lxzx.appDTO.lxlbDTO.SearchDTO;
import com.ruoyi.lxzx.appVO.lxjhVO.BmrVO;
import com.ruoyi.lxzx.appVO.lxlbVO.LxlbListDetailVO;
import com.ruoyi.lxzx.appVO.lxlbVO.LxlbListVO;
import com.ruoyi.lxzx.domain.UserCard;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * 用户名片Mapper接口
 *
 * @author ruoyi
 * @date 2024-10-26
 */
public interface UserCardMapper {
    /**
     * 查询用户名片
     *
     * @param id 用户名片主键
     * @return 用户名片
     */
    public UserCard selectUserCardById(Long id);

    /**
     * 查询用户名片列表
     *
     * @param userCard 用户名片
     * @return 用户名片集合
     */
    public List<UserCard> selectUserCardList(UserCard userCard);

    /**
     * 新增用户名片
     *
     * @param userCard 用户名片
     * @return 结果
     */
    public int insertUserCard(UserCard userCard);

    /**
     * 修改用户名片
     *
     * @param userCard 用户名片
     * @return 结果
     */
    public int updateUserCard(UserCard userCard);

    /**
     * 删除用户名片
     *
     * @param id 用户名片主键
     * @return 结果
     */
    public int deleteUserCardById(Long id);

    /**
     * 批量删除用户名片
     *
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteUserCardByIds(Long[] ids);

    List<LxlbListVO> lxlb(@Param("param") SearchDTO param);

    LxlbListDetailVO ckmp(@Param("userId") Long userId);

    @Select("select address from user_card where user_id=#{userId}")
    String hqdz(@Param("userId") Long userId);

    List<UserCard> findUserCardList(@Param("activityId") Long activityId);

    LxlbListDetailVO findUserCardByName(@Param("createBy") String createBy);

    @Select("SELECT uc.id as id,uc.user_id as userId,uc.tel as tel,uc.img as img,uc.address as address,uc.address_prov as addressProv, uc.address_city as addressCity,uc.address_present as addressPresent,\n" +
            "uc.lat as lat,uc.lon as lon ,uc.comp_name as compName,uc.profession as profession,uc.industry as industry,uc.email as email,uc.wx_code as wxCode,uc.per_describe as perDescribe,\n" +
            "uc.comp_describe_img as compDescribeImg,uc.comp_describe_video as compDescribeVideo,uc.is_real as isReal,uc.is_card as isCard,\n" +
            "( SELECT nick_name FROM sys_user su WHERE su.user_id = uc.user_id ) AS NAME \n" +
            "FROM user_card uc \n" +
            "where uc.user_id in (SELECT user_id FROM activity_apply aa WHERE aa.activity_id = #{activityId})" +
            " and uc.is_card = 1\n" +
            "        order by uc.create_time desc")
    List<BmrVO> hdjhybmr(@Param("activityId") Long activityId);

    UserCard findByUserId(Long userId);

    void updateUserCardRead(UserCard uc);
    int updateUserRemoveCard(UserCard uc);
    List<LxlbListVO> sqgl(@Param("userId") Long userId);

    List<LxlbListVO> wdgz(@Param("userId") Long userId);

    @Update("update user_card set address_present = #{addressPresent} where user_id = #{finalUserId}")
    void gxxjd(@Param("addressPresent") String addressPresent, @Param("finalUserId") Long finalUserId);

    @Update("update user_card set img = #{img} where user_id = #{finalUserId}")
    void xgtx(@Param("finalUserId") Long finalUserId, @Param("img") String img);
}
